#ifndef PIN_H__
#define PIN_H__

#include "hc32_common.h"
#include "hc32f460_gpio.h"
uint32_t get_pin(en_port_t enPort, uint16_t u16Pin);
#define __HC32_PORT(port)  Port##port
#define GET_PIN(PORTx,PIN) (__HC32_PORT(PORTx)*0x40+PIN*0x04)

#define PIN_LOW                 		0x00
#define PIN_HIGH                		0x01

#define PIN_MODE_OUTPUT         		0x00
#define PIN_MODE_OUTPUT_PULLUP			0x01
#define PIN_MODE_INPUT          		0x02
#define PIN_MODE_INPUT_PULLUP   		0x03
#define PIN_MODE_INPUT_PULLDOWN 		0x04
#define PIN_MODE_OUTPUT_OD      		0x05

#define PIN_IRQ_MODE_RISING             0x00
#define PIN_IRQ_MODE_FALLING            0x01
#define PIN_IRQ_MODE_RISING_FALLING     0x02
#define PIN_IRQ_MODE_HIGH_LEVEL         0x03
#define PIN_IRQ_MODE_LOW_LEVEL          0x04

#define PIN_IRQ_DISABLE                 0x00
#define PIN_IRQ_ENABLE                  0x01

void hc32_pin_set_func(uint32_t pin,en_port_func_t enFuncSel,uint8_t enable);
void hc32_pin_mode(uint32_t pin,uint32_t mode);
void hc32_pin_write(uint32_t pin,uint32_t value);
uint8_t hc32_pin_read(uint32_t pin);
void hc32_pin_attach_irq(uint32_t pin, uint32_t mode,void (*hdr)(void));
void hc32_pin_irq_enable(uint32_t pin, uint32_t enabled);
void hc32_pin_wake_src_enable(uint32_t pin,uint8_t enable);
void jlink_Disable(void);
#endif